<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>项目名称：</p>
                                <input type="text" name="proName"/>
                            </li>
                            <li>
                                <p>事项名称：</p>
                                <input type="text" name="matterProjectName"/>
                            </li>
                            <li>
                                <p>项目类型：</p>
                                <select name="proType" th:with="type=${@dict.getType('project_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>项目投资：</p>
                                <input type="text" name="investmentAmount"/>
                            </li>
                            <li>
                                <p>企业联系人：</p>
                                <input type="text" name="leader"/>
                            </li>
                            <!--<li>-->
                                <!--<p>项目类型：</p>-->
                                <!--<select name="proType" >-->
                                    <!--<option value="">所有</option>-->
                                    <!--<option value="0">前期阶段</option>-->
                                    <!--<option value="1">拟开工阶段</option>-->
                                    <!--<option value="2">在建阶段</option>-->
                                    <!--<option value="3">竣工阶段</option>-->

                                <!--</select>-->
                            <!--</li>-->
<!--                            <li>-->
<!--                                <p>项目状态：</p>-->
<!--                                <select name="proStatus">-->
<!--                                    <option value="">所有</option>-->
<!--                                </select>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="add()" shiro:hasPermission="linkong:project:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="edit()" shiro:hasPermission="linkong:project:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="linkong:project:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="linkong:project:export">-->
                    <!--<i class="fa fa-download"></i> 导出-->
                 <!--</a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('linkong:project:edit')}]];
        var removeFlag = [[${@permission.hasPermi('linkong:project:remove')}]];
        var instructionsList = [[${@permission.hasPermi('linkong:instructions:list')}]];
        var prefix = ctx + "linkong/project";
        var datas = [[${@dict.getType('project_type')}]];
        var types = [[${@dict.getType('project_tag')}]];
        var stages = [[${@dict.getType('project_stage')}]];
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "项目",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'proId', 
                    title : '项目ID',
                    visible: false
                },
                {
                    field : 'companyName',
                    align: 'center',
                    title : '企业名称'
                },
                {
                    field : 'proName',
                    align: 'center',
                    title : '项目名称'
                },
                {
                    field : 'tabName',
                    title : '项目标签',
                    align: 'center',
                    width : '8%'
                    // formatter: function(value, row, index) {
                    //     return $.table.selectDictLabel2(types, value);
                    // }
                },
                {
                    field : 'proCode',
                    align: 'center',
                    title : '项目编码'
                },
                {
                    field : 'leader',
                    align: 'center',
                    title : '企业联系人'
                },
                    {
                        field : 'leaderPhone',
                        title : '法人手机号',
                        align: 'center',
                        formatter : function (value) {
                            return value == null?"-":value.substr(0,3) + "****" + value.substr(7)
                        }
                    },

                {
                    field : 'investmentAmount',
                    align: 'center',
                    title : '项目投资(万)'
                },
                // {
                //     field : 'startTime',
                //     title : '计划开始时间',
                //     formatter: function(value, row, index) {
                //         return value == null?'':value.substr(0,10);
                //     }
                // },
                {
                    field : 'transitionTime', 
                    title : '移交日期',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return value == null?'':value.substr(0,10);
                    }
                },
                // {
                //     field : 'startTime',
                //     title : '开始时间',
                //     align: 'center',
                //     formatter: function(value, row, index) {
                //         return value == null?'':value.substr(0,10);
                //     }
                // },
                //     {
                //         field : 'endTime',
                //         title : '截止时间',
                //         align: 'center',
                //         formatter: function(value, row, index) {
                //             return value == null?'-':value.substr(0,10);
                //         }
                //     },

                {
                    field : 'proType',
                    title : '项目类型',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                // {
                //     field : 'proStage',
                //     title : '项目状态',
                //     formatter: function(value, row, index) {
                //         return $.table.selectDictLabel(stages, value);
                //     }
                // },
                //     {
                //         field : 'proMatterIds',
                //         title : '事项',
                //         visible: false
                //     },
                {
                    field : 'remark',
                    title : '简介',
                    width : '8%',
                    formatter: function(value, row, index) {

                        // return value== ''?'':value.substr(0,20)+"...";
                        return $.table.tooltip(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="see(\'' + row.proId + '\')"><i class="fa fa-search-plus"></i>查看</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + instructionsList + '" href="javascript:void(0)" onclick="viewInstructions(\'' + row.proId + '\')"><i class="fa fa-search-plus"></i>查看批示</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="edit(\'' + row.proId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.proId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('&nbsp;<a class="btn btn-primary btn-xs ' + removeFlag + '"  href="javascript:void(0)" onclick="setMatter(' + row.proId + ',' + '\'' + row.proMatterIds + '\')"><i class="fa fa-cog"></i>配置事项</a>');
                        var userRole = [[${@permission.getPrincipalProperty('roleKey')}]];
                        if (userRole == 'dept' || userRole == 'company') {
                            actions.push('&nbsp;<a class="btn btn-info btn-xs  href="javascript:void(0)" onclick="auditMatter(' + row.proId + ',' + '\'' + row.proMatterIds + '\')"><i class="fa fa-key"></i>事项处理</a>');
                        }
                        if (userRole == 'peojectAdmin') {
                            actions.push('&nbsp;<a class="btn btn-info btn-xs  href="javascript:void(0)" onclick="auditMatter(' + row.proId + ',' + '\'' + row.proMatterIds + '\')"><i class="fa fa-key"></i>审核</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function add(id){
            $.modal.open("添加" + $.table._option.modalName, $.operate.addUrl(id),1000,600);
        }

        function edit(id){
            $.modal.open("编辑" + $.table._option.modalName, $.operate.editUrl(id),1000,600);
        }
        function see(id){
            var options = {
                url: $.operate.editUrl(id) + "?flag=see",
                title: $.table._option.modalName + "详情",
                width:1000,
                height:600,
                btn :[ '<i class="fa fa-close"></i> 关闭'],
                callBack:closeTab
            }
            $.modal.openOptions(options);

        }

        function closeTab(index){
            layer.close(index);
        }

        function setMatter(proId,ids){
            $.modal.open("配置事项", prefix + "/matter_edit/" + proId + "?ids=" + ids,1400);
        }
        
        function auditMatter(proId,ids){
            $.modal.open("审核事项", prefix + "/matter_audit/" + proId + "?ids=" + ids + "&flasAuditOrView=true",1400);
        }

        function viewInstructions(proId){
            $.modal.open('批示',"/linkong/instructions/view/" + proId, '900', ($(window).height() - 50));
        }
    </script>
</body>
</html>
